#!/usr/bin/env bash
. ./scripts/devcontainer/_assert-in-container "$0" "$@"

set -euo pipefail

# Tell rollbar about a deploy

LOCAL_USERNAME="$(grep 'account' ~/.config/gcloud/configurations/config_default | awk '{print $3}' | awk -F "@" '{print $1}')"

curl -s https://api.rollbar.com/api/1/deploy/ \
  -F "access_token=${DARK_CONFIG_ROLLBAR_POST_SERVER_ITEM}" \
  -F "environment=production" \
  -F "revision=$(git rev-parse --short HEAD)" \
  -F "comment=$1" \
  -F "local_username=${LOCAL_USERNAME}" > /dev/null
echo "Rollbar notified."

